import os

import yaml

# 获取项目路径
def get_object_path():
    return os.path.abspath(os.getcwd().split("common")[0])

# 读取config文件
def read_config_file(one_node,two_node):
   with open(get_object_path()+"config.yaml",encoding="utf-8") as f:
       value=yaml.load(stream=f,Loader=yaml.FullLoader)
       return value[one_node][two_node]


def read_extract_file(node):
   with open(get_object_path()+"extract.yaml",encoding="utf-8") as f:
       value=yaml.load(stream=f,Loader=yaml.FullLoader)
       return value[node]

def write_extract_file(data):
   with open(get_object_path()+"extract.yaml",encoding="utf-8",mode="a") as f:
       yaml.dump(data,stream=f,allow_unicode=True)

def clear_extract_file(data):
   with open(get_object_path()+"extract.yaml",encoding="utf-8",mode="w") as f:
       f.truncate()


if __name__ == '__main__':
    print(get_object_path())
    print(read_config_file("base","base_gzh_url"))